import * as FileApi from '/@/serve/api/fileSystem';

/**
 * 获取文件集合并格式化为级联选项集合
 * @param path 文件根目录
 * @returns
 */
export const getOptions = (path: string = '/') => {
  return new Promise((resolve) => {
    FileApi.getFileSystem(path).then((res: any) => {
      const options: Array<any> = [];
      res.content.forEach((file: any) => {
        options.push({
          label: file.filename,
          value: `/${file.filename}`,
          isLeaf: file.isLeaf,
        });
      });
      resolve(options);
    });
  });
};
